package com.demo.config;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import reactor.core.publisher.Mono;

/**
 * @author: demo
 * @date: 2020年6月23日
 * @Document : api+host 限流策略
 */
@Configuration
public class RequestRateLimiterConfig {

    
    @Bean
    public KeyResolver apiAndIpKeyResolver() {
        return exchange ->  Mono.just(exchange.getRequest().getRemoteAddress().getHostName()+exchange.getRequest().getPath().value());
    }

}
